package entity.file;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

@SuppressWarnings("serial")
@Entity
@Table(name = "file")
public class MyFile implements Serializable {

	private String id;
	private double size;// 文件大小
	private String md5value;// 文件对应的md5值
	private String type;// 文件类型
	private Date date = new Date();// 文件上传时间
	private int usetimes = 0;// 该文件被引用的次数
	private String path;// 文件存放路径
	private List<FileName> fileNames = new ArrayList<>(0);

	
	
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "ID", unique = true, nullable = false, length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "size")
	public double getSize() {
		return size;
	}

	public void setSize(double size) {
		this.size = size;
	}
	               
	@Column(name = "md5value", length = 32)
	public String getMd5value() {
		return md5value;
	}

	public void setMd5value(String md5value) {
		this.md5value = md5value;
	}

	@Column(name = "type", length = 50)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date")
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Column(name = "usetimes")
	public int getUsetimes() {
		return usetimes;
	}

	public void setUsetimes(int usetimes) {
		this.usetimes = usetimes;
	}

	@Column(name = "path", length = 400)
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "myFile")
	public List<FileName> getFileNames() {
		return fileNames;
	}

	public void setFileNames(List<FileName> fileNames) {
		this.fileNames = fileNames;
	}

}
